libxl: add query function for backend support by device model
authorJuergen Gross <jgross@suse.com>
Wed, 30 Mar 2016 10:45:10 +0000 (12:45 +0200)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 6 Apr 2016 13:58:02 +0000 (14:58 +0100)
Add a function to query whether the device model is supporting a
specific backend type. The device model is writing the supported
backend types to Xenstore on startup. The new query function checks
for the appropriate entry to be present.

As not all versions of qemu are capable to indicate support of
specific backends the query function is to be called with an indicator
whether the default return value should be "supported" (in case qemu
doesn't know set any support information) or "not supported".

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
docs/misc/xenstore-paths.markdown
tools/libxl/libxl_dm.c
tools/libxl/libxl_internal.h

index 087e239faae1b105c90eccb6eea922a4f3568d72..7d5a06a47e401aa390db404c9c51e7a378597a91 100644 (file)
@@ -482,6 +482,13 @@ in the value supplied by the guest in this case).
 
 Contains the status of the device models running on the domain.
 
+#### ~/device-model/$DOMID/backends/* [w]
+
+Backend types the device model is supporting. Each entry below backends
+is a directory which may contain further nodes specific to the backend
+type. The name of each backend directory is the same as the backend type
+(e.g. "qdisk").
+
 #### ~/libxl/$DOMID/qdisk-backend-pid [w]
 
 Contains the PIDs of the device models running on the domain.
index 29f6a37d1c722d0ee87cde1a6c861398045729b7..d2bb5ca8ef908d541466f65e764a4f6f50228790 100644 (file)
@@ -2118,6 +2118,25 @@ out:
         device_model_spawn_outcome(egc, dmss, rc);
 }
 
+bool libxl__query_qemu_backend(libxl__gc *gc, uint32_t domid,
+                               uint32_t backend_id, const char *type, bool def)
+{
+    char *path;
+    char **dir;
+    unsigned int n;
+
+    path = GCSPRINTF("%s/device-model/%u/backends",
+                     libxl__xs_get_dompath(gc, backend_id), domid);
+    dir = libxl__xs_directory(gc, XBT_NULL, path, &n);
+    if (!dir)
+        return def;
+
+    path = GCSPRINTF("%s/device-model/%u/backends/%s",
+                     libxl__xs_get_dompath(gc, backend_id), domid, type);
+    dir = libxl__xs_directory(gc, XBT_NULL, path, &n);
+
+    return !!dir;
+}
 
 static void device_model_confirm(libxl__egc *egc, libxl__spawn_state *spawn,
                                  const char *xsdata)
index 0896c0d85e44b8a90633c7747e934128f0f7357a..dbf0bd7a4266189c4f5094623a3317618d562e28 100644 (file)
@@ -1619,6 +1619,11 @@ _hidden const char *libxl__domain_device_model(libxl__gc *gc,
                                         const libxl_domain_build_info *info);
 _hidden int libxl__need_xenpv_qemu(libxl__gc *gc,
                                    libxl_domain_config *d_config);
+_hidden bool libxl__query_qemu_backend(libxl__gc *gc,
+                                       uint32_t domid,
+                                       uint32_t backend_id,
+                                       const char *type,
+                                       bool def);
 
 /*
  * This function will fix reserved device memory conflict